//
//  AppendXGFishpondHeaderView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/9/11.
//

#import "AppendXGFishpondHeaderView.h"
#import "YTBaseSelectStringView.h"
#import "YTBaseEditorStringView.h"


@interface AppendXGFishpondHeaderView ()
///池塘类型
@property (nonatomic ,strong)  YTBaseSelectStringView * SZFSview;
@property (nonatomic ,strong)  YTBaseSelectStringView * typeName;
@property (nonatomic ,strong)  YTBaseEditorStringView * name;

@property (nonatomic ,strong)  YTBaseSelectStringView * tissueName;

@end
@implementation AppendXGFishpondHeaderView

+ (instancetype)NewView{
    AppendXGFishpondHeaderView * view = [AppendXGFishpondHeaderView new];
    view.backgroundColor = UIColor.whiteColor;
    [view setupView];
    return view;
}

- (void)setupView{
 
    
    MJWeakSelf
    YTBaseSelectStringView * SZFSview = [YTBaseSelectStringView NewView];
    self.SZFSview = SZFSview;
    SZFSview.forceFlag = YES;
    SZFSview.name = @"设置方式";
    SZFSview.block = ^(NSString * _Nonnull content) {
        if(weakSelf.openSZFSBlock){
            weakSelf.openSZFSBlock(weakSelf.model);
        }
    };
    [self addSubview:SZFSview];
    [SZFSview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.offset(0);
        make.height.offset(kwt(60));
    }];
    
    
    YTBaseSelectStringView * typeName = [YTBaseSelectStringView NewView];
    self.typeName = typeName;
    typeName.forceFlag = YES;
    typeName.name = @"池塘类型";
    typeName.block = ^(NSString * _Nonnull content) {
        if(weakSelf.openTKLXBlock){
            weakSelf.openTKLXBlock(weakSelf.model);
        }
    };
    [self addSubview:typeName];
    [typeName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(SZFSview.mas_bottom);
        make.height.offset(kwt(60));
    }];
    
    YTBaseEditorStringView * name = [YTBaseEditorStringView NewView];
    self.name = name;
    name.forceFlag = YES;
    name.name = @"池塘名称";
    name.block = ^(NSString * _Nonnull content) {
        weakSelf.model.name = content;
    };
    [self addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(typeName.mas_bottom);
        make.height.offset(kwt(60));

    }];
    
    YTBaseSelectStringView * tissueName = [YTBaseSelectStringView NewView];
    self.tissueName = tissueName;
    tissueName.forceFlag = YES;
    tissueName.name = @"池塘编组";
    [self addSubview:tissueName];
    [tissueName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(name.mas_bottom);
        make.height.offset(kwt(60));

    }];
    tissueName.block = ^(NSString * _Nonnull content) {
        if(weakSelf.openTKBZBlock){
            weakSelf.openTKBZBlock(weakSelf.model);
        }
    };
}


-(void)setModel:(AddXGPondModel *)model {
    _model = model;
    [self.SZFSview mas_updateConstraints:^(MASConstraintMaker *make) {
//        if(model.typeCode == 0 || model.addPondModelList.count < 2){
        if(model.addPondModelList.count < 1){
            make.height.offset(0);
        } else {
            make.height.offset(kwt(60));
        }
    }];
    self.SZFSview.content = model.isAll?@"同步设置":@"设置当前池塘";
    self.typeName.content = model.typeName;
    self.name.content = model.name;
    self.tissueName.content = model.tissueName;
     
}

@end
